<template lang="jade">
div.return-bar
	i.iconfont(@click="back()") &#xe668;
	排名列表
div.user-auto.detail_top
	ul.ranking
		li(:is="currentView",v-for="(index, item) in items ", :item="item", :tel="tel")

	//button.obtn(@click="back()") 返回
</template>

<script>
import '../../assets/sass/user/auto-buy.scss'
import RankingPage from '../../components/other/ranking'
import {Api_Get_Ranking} from '../../config/api'


export default {
	data(){
		return{
			currentView:'',
			items: [],
			obj: [],
			tel:''
		}
	},

	components:{
		rankpage:RankingPage
	},


	methods:{
		back(){
			this.$route.router.go('/auto-buy')
		},
		fetch(){
			this.currentView = 'rankpage';
			var that = this;
			this.$http({url:Api_Get_Ranking, methods:"GET"}).then(function(res){

				var obj = res.data;
				if(!obj.status){
					alert(obj.msg)
					if(obj.code == '10055'){
						sessionStorage.removeItem("login"); 
						this.$route.router.go('/login?from='+this.$route.path.substring(1))
					}
					return;
				}

				//console.log(res.data.list)
				that.tel = localStorage.getItem("tel");
        		that.items = that.items.concat(res.data.list);
        		//that.obj = Object.assign([], that.obj.concat(res.data.list));

			});
		}
	},

	route:{
		activate(transition){

			this.fetch();
			transition.next();
		}
	}

}

</script>